<article class="module width_full">
	<header><h3><%= t(:stats) %></h3></header>
	<div class="module_content">
		<article class="stats_graph">
			<h4><%= t(:projects) %></h4>
			<% Project.all.each do |p| %>
			  <div style="margin: 10px 0 0 10px;">
			    <div class="bar bg-gray">
			      <%= image_tag 'folder.png', :align => :absmiddle, :height => 16, :with => 16 %>
			      <%= link_to p.name, p %></div>
			    <table with="300">
			      <% total = p.issues.count %>
			      <% ['open', 'working_on', 'closed'].each do |state| %>
			        <% state_count = p.issues.send("only_#{state}").count %>
			        <% percent = total > 0 ? state_count * 100 / total : 0; %>
			        <tr>
			          <td width="50"><%= t("issue.state.#{state}") %></td>
			          <td>
			            <%= link_to "#{percent}%", "/projects/#{p.id}/filter/#{state}",
			                  :class => "percent_bar state-#{state}",
			                  :style => "width: #{percent < 20 ? percent + 10 : percent}%"
			            %>
			          </td>
			        </tr>
			      <% end %>
			    </table>
			  </div>
			<% end %>
		</article>

		<article class="stats_overview">
			<div class="overview_today">
				<p class="overview_count"><%= Project.count %></p>
				<p class="overview_type"><%= t(:projects) %></p>
				<p class="overview_count"><%= User.count %></p>
				<p class="overview_type"><%= t(:people)%></p>
			</div>
			<div class="overview_previous">
				<p class="overview_count"><%= Issue.count %></p>
				<p class="overview_type"><%= t(:issues) %></p>
				<p class="overview_count"><%= TodoItem.count %></p>
				<p class="overview_type"><%= t(:todo) %></p>
			</div>
		</article>
		<div class="clear"></div>
	</div>
</article>
<!-- end of stats article -->

